package xyz.jangle.io;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class MainTest2 {

	public static void main(String[] args) {
		
        try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream()){
        	byte[] b = "1234567890".getBytes();
			outputStream.write(b);
			
			ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
			InputStream in = new BufferedInputStream(inputStream);
			OutputStream out = new BufferedOutputStream(new FileOutputStream(new File("test3.txt")));
			int c=0;
			while((c = in.read()) != -1) {
				out.write(c);
			}
			/*
			byte[] d = new byte[8];
			int n =0;
			while((n=in.read(d, 0, 8) )!= -1) {
				out.write(d, 0, n);
			}*/
			
			in.close();
			out.flush();
			out.close();
        	
        } catch (IOException e) {
			e.printStackTrace();
		}
        

	}

}
